package com.example.patient.controller;

import com.example.common.support.Result;
import com.example.patient.dto.req.*;
import com.example.patient.dto.resp.*;
import com.example.patient.service.LoginService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @Author wxy
 * @Date 2021/1/18 9:58
 * @Version 1.0
 */
@RestController
@Api(tags = "登录")
@RequestMapping("/api/Login")
public class LoginController {
    @Resource
    private LoginService loginService;

    @ApiOperation(value = "登录信息", notes = "登录信息")
    @PostMapping(value = "/getClientInfo")
    public Result<GetClientInfoResp> getClientInfo() {
        return Result.success(loginService.getClientInfo());
    }

    @ApiOperation(value = "微信信息", notes = "微信信息")
    @PostMapping(value = "/GetWcInfo")
    public Result<GetWcInfoResp> GetWcInfo(@RequestBody GetWcInfoReq req) {
        return Result.success(loginService.GetWcInfo(req));
    }

    @ApiOperation(value = "发送短信", notes = "发送短信")
    @PostMapping(value = "/SendCode")
    public Result<SendCodeResp> SendCode(@RequestBody SendCodeReq req) {
        return Result.success(loginService.SendCode(req));
    }

    @ApiOperation(value = "短信登录", notes = "短信登录")
    @PostMapping(value = "/DoSMSLogin")
    public Result<DoSMSLoginResp> DoSMSLogin(@RequestBody DoSMSLoginReq req) {
        return Result.success(loginService.DoSMSLogin(req));
    }

    @ApiOperation(value = "通过code换取openid和UID (正式）", notes = "通过code换取openid和UID (正式）")
    @PostMapping(value = "/getWxInfoR")
    public Result<getWxInfoRResp> getWxInfoR(@RequestBody getWxInfoRReq req) {
        return Result.success(loginService.getWxInfoR(req));
    }

    @ApiOperation(value = "获取电话", notes = "获取电话")
    @PostMapping(value = "/GetUserTel")
    public Result<GetUserTelResp> GetUserTel(@RequestBody GetUserTelReq req) {
        return Result.success(loginService.GetUserTel(req));
    }
}
